define(function (require) {
    var utils = require('common/utils/home');
    return {
        //登录
        islogin: function () {
            return "" == _global.uid ? (this.login(), !1) : !0;
            //return def.is_login;
        },
        login: function () {
            $.getJSON(PINER.root + '/?m=passport&a=login', function (result) {
                if (result.status == 0) {
                    $.zhiphp.tip({content: result.msg, icon: 'error'});
                } else {
                    $.dialog({id: 'login', title: lang.login_title, content: result.data, padding: '', fixed: true, lock: true});
                    $.zhiphp.dialog.dlogin_form($('#J_dlogin_form'));
                }
            });
        },
        dlogin_form: function (form) {
            form.ajaxForm({
                beforeSubmit: function () {
                    var username = form.find('.J_username').val(),
                        password = form.find('.J_password').val();
                    if (username == '') {
                        form.find('#J_login_fail').html('请输入用户名！').css("visibility", 'visible');
                        return !1;
                    }
                    if (password == '') {
                        form.find('#J_login_fail').html('请输入密码！').css("visibility", 'visible');
                        return !1;
                    }
                },
                success: function (result) {
                    if (result.status == 1) {
                        $.dialog.get('login').title(false).content('<div class="d_loading">' + result.msg + '</div>').time(2000);
                        window.location.reload();
                    } else {
                        form.find('#J_login_fail').html(result.msg).css("visibility", 'visible');
                    }
                },
                dataType: 'json'
            });
        }
    };
});